#!/bin/sh
# This regression test is a part of SIPp.
# <recv timeout> may contain keywords, here a CSV field, so each call
# has its own receive timeout.
. "`dirname "$0"`/../functions"; init

printf 'SEQUENTIAL\n200;\n1500;\n' >timeouts.csv
start=`date +%s%N`
sippfg -sf uac.xml -inf timeouts.csv -m 2 -l 1 -nr -i 127.0.0.1 -p 25900 \
    127.0.0.1:25901 -timeout 8 -timeout_error >/dev/null 2>&1
status=$?
elapsed=$(( (`date +%s%N` - start) / 1000000 ))
rm -f timeouts.csv

if test $status -ne 0; then
    fail "UAC failed with $status"
elif test $elapsed -lt 1700 -o $elapsed -gt 5000; then
    fail "the calls took ${elapsed}ms, not about 1700ms"
else
    ok
fi
